tg-me.com/r_riscv/3338
Last Update:
Can't step through code in VS Code + OpenOCD + GDB with RISC-V — everything connects but stepping doesn't work
Hi! I'm setting up debugging for a RISC-V project in VS Code using the Cortex-Debug extension. I'm using OpenOCD and `riscv32-unknown-elf-gdb`. The configuration seems to launch correctly: OpenOCD starts, GDB connects, and the ELF file (`main.elf`) is loaded. A breakpoint in `main()` also sets successfully.
But then I run into problems:
* After `exec-continue`, the program stops at `0x00010058 in ?? ()`.
* The breakpoint in `main()` doesn’t hit, and I can’t step through the code (step over / step into doesn’t work).
* `main()` is at `0x400000c0`, and the ELF is built with `-g`, but something is clearly off.
# What I’ve checked:
* `"showDevDebugOutput": "parsed"` is set
* The ELF file contains debug symbols (verified with `nm`, `objdump`)
* Using custom `riscv.cfg` and my own `startup.S`
* Using `riscv32-unknown-elf-gdb` and OpenOCD listening on `localhost:50000`
* `readelf` shows the entry point does **not** match the address of `main()`
launch.json
{
"configurations": [
{
"name": "RISCV",
"type": "cortex-debug",
"request": "launch",
// "showDevDebugOutput": "parsed",
"servertype": "openocd",
"cwd": "${workspaceFolder}",
"executable": "./build/main.elf",
"gdbTarget": "localhost:50000",
"configFiles": [
"lib/riscv.cfg"
],
"postLaunchCommands": [
"load"
],
"runToEntryPoint": "main"
}
]
}
settings.json
{
"cortex-debug.openocdPath": "/usr/bin/openocd",
"cortex-debug.variableUseNaturalFormat": true,
"cortex-debug.gdbPath": "/home/riscv/bin/riscv32-unknown-elf-gdb",
"search.exclude": {
"**/build": true
},
"files.associations": {
"printf_uart.h": "c"
}
}
https://redd.it/1kr1rao
@r_riscv
BY RISC-V Reddit

Share with your friend now:
tg-me.com/r_riscv/3338